From a8d2b993b0d79fc00f11879eded4d0cd7e21e7d4 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 11 Sep 2004 06:58:47 +0000 Subject: [PATCH] * Sensible error messages when illegal title chars given in username * Don't double the login form when asked to send pass for no email user Fixes bug 448: failure message on "mail password" is shown twice http://bugzilla.wikipedia.org/show_bug.cgi?id=448 --- includes/SpecialUserlogin.php | 16 ++++++++++++---- includes/User.php | 8 ++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 32e88b532e..bd78387c72 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -162,7 +162,8 @@ class LoginForm { $name = trim( $this->mName ); $u = User::newFromName( $name ); - if ( ( "" == $name ) || + if ( is_null( $u ) || + ( "" == $name ) || preg_match( "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/", $name ) || (strpos( $name, "/" ) !== false) || (strlen( $name ) > $wgMaxNameChars) || @@ -217,6 +218,10 @@ class LoginForm { return; } $u = User::newFromName( $this->mName ); + if( is_null( $u ) ) { + $this->mainLoginForm( wfMsg( "noname" ) ); + return; + } $id = $u->idForName(); if ( 0 == $id ) { $this->mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) ); @@ -264,6 +269,10 @@ class LoginForm { return; } $u = User::newFromName( $this->mName ); + if( is_null( $u ) ) { + $this->mainLoginForm( wfMsg( "noname" ) ); + return; + } $id = $u->idForName(); if ( 0 == $id ) { $this->mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) ); @@ -291,8 +300,7 @@ class LoginForm { global $wgCookiePath, $wgCookieDomain; if ( "" == $u->getEmail() ) { - $this->mainLoginForm( wfMsg( "noemail", $u->getName() ) ); - return; + return wfMsg( "noemail", $u->getName() ); } $np = User::randomPassword(); $u->setNewpassword( $np ); @@ -355,7 +363,7 @@ class LoginForm { $ca = wfMsg( "createaccount" ); $cam = wfMsg( "createaccountmail" ); $ye = wfMsg( "youremail" ); - if ($wgAllowRealName) { + if( $wgAllowRealName ) { $yrn = wfMsg( "yourrealname" ); } else { $yrn = ''; diff --git a/includes/User.php b/includes/User.php index 6c8c9caa73..19b51a5004 100644 --- a/includes/User.php +++ b/includes/User.php @@ -45,8 +45,12 @@ class User { # Clean up name according to title rules $t = Title::newFromText( $name ); - $u->setName( $t->getText() ); - return $u; + if( is_null( $t ) ) { + return NULL; + } else { + $u->setName( $t->getText() ); + return $u; + } } /** -- 2.20.1